<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>#MaxThreads</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>#MaxThreads</h1>

<p>Sets the maximum number of simultaneous <a href="../misc/Threads.htm">threads</a>.</p>

<pre class="Syntax">#MaxThreads Value</pre>
<h3>Parameters</h3>
<dl>

  <dt>Value</dt>
  <dd><p>The maximum total number of <a href="../misc/Threads.htm">threads</a> that can exist simultaneously. Specifying a number higher than 255 is the same as specifying 255 (in versions prior to 1.0.48, the limit was 20).</p></dd>

</dl>
<h3>Remarks</h3>
<p>This setting is global, meaning that it needs to be specified only once (anywhere in the script) to affect the behavior of the entire script.</p>
<p>Although  a value of 1 is allowed, it is not recommended because it would prevent new <a href="../Hotkeys.htm">hotkeys</a> from launching whenever the script is displaying a <a href="MsgBox.htm">MsgBox</a> or other dialog. It would also prevent <a href="SetTimer.htm">timers</a> from running whenever another <a href="../misc/Threads.htm">thread</a> is sleeping or waiting.</p>
<p>Up to two of the following types of <a href="../misc/Threads.htm">threads</a> may be created even when #MaxThreads has been reached: A <a href="../Hotkeys.htm">hotkey</a>, <a href="../Hotstrings.htm">hotstring</a>, <a href="OnClipboardChange.htm">OnClipboardChange</a>, or <a href="Gui.htm#Events">GUI event</a> if the first line of its subroutine is <a href="ExitApp.htm">ExitApp</a>, <a href="Pause.htm">Pause</a>, <a href="Edit.htm">Edit</a>, <a href="Reload.htm">Reload</a>, <a href="KeyHistory.htm">KeyHistory</a>, <a href="ListLines.htm">ListLines</a>, <a href="ListVars.htm">ListVars</a>, or <a href="ListHotkeys.htm">ListHotkeys</a>. Also, the <a href="OnExit.htm">OnExit subroutine</a> will always launch regardless of how many threads exist.</p>
<p>If this setting is lower than <a href="_MaxThreadsPerHotkey.htm">#MaxThreadsPerHotkey</a>, it effectively overrides that setting.</p>
<p>If this directive is unspecified in the script, it will behave as though set to 10.</p>
<h3>Related</h3>
<p><a href="_MaxThreadsPerHotkey.htm">#MaxThreadsPerHotkey</a>, <a href="../misc/Threads.htm">Threads</a>, <a href="_MaxHotkeysPerInterval.htm">#MaxHotkeysPerInterval</a>, <a href="_HotkeyInterval.htm">#HotkeyInterval</a>, <a href="ListHotkeys.htm">ListHotkeys</a>, <a href="_MaxMem.htm">#MaxMem</a></p>
<h3>Example</h3>
<pre class="NoIndent">#MaxThreads 2</pre>

</body>
</html>
